//
//  JCRepaymentCell.m
//  JiFengDaRen
//
//  Created by shouhan on 2018/3/29.
//  Copyright © 2018年 陈永发. All rights reserved.
//

#import "JCRepaymentCell.h"

@interface JCRepaymentCell ()

@property (nonatomic, strong) UIView * progressView;

@property (nonatomic, strong) UIView * manageView;

@property (nonatomic, strong) UIImageView * progressImage;

@property (nonatomic, strong) UIImageView * manageImage;

@property (nonatomic, strong) UILabel * progressLabel;

@property (nonatomic, strong) UILabel * manageLabel;


@end

@implementation JCRepaymentCell

+ (instancetype)tableViewCellWithTableView:(UITableView *)tableView{
    static NSString * cellIndentfile = @"JCRepaymentCell";
    JCRepaymentCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIndentfile];
    
    if (!cell) {
        cell = [[JCRepaymentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndentfile];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}

- (void)initUI{
    
    self.contentView.backgroundColor = [UIColor colorWithHexString:@"#F7F8FB"];
    
    self.manageView = [UIView new];
    self.manageView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.manageView];
    
    self.progressView = [UIView new];
    self.progressView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.progressView];

    self.progressImage = [UIImageView new];
    self.progressImage.image = [UIImage imageNamed:@"icon_time"];
    [self.progressView addSubview:self.progressImage];
    
    self.progressLabel = [UILabel new];
    self.progressLabel.text = @"进度查询";
    self.progressLabel.font = KSHSystemFont(14);
    self.progressLabel.textColor = [UIColor colorWithHexString:@"#2C2C2C"];
    [self.progressView addSubview:self.progressLabel];
    
    self.manageImage = [UIImageView new];
    self.manageImage.image = [UIImage imageNamed:@"icon_bankcard2"];
    [self.manageView addSubview:self.manageImage];
    
    self.manageLabel = [UILabel new];
    self.manageLabel.text = @"信用卡管理";
    self.manageLabel.font = KSHSystemFont(14);
    self.manageLabel.textColor = [UIColor colorWithHexString:@"#2C2C2C"];
    [self.manageView addSubview:self.manageLabel];
    
}


- (void)layoutSubviews{
    [super layoutSubviews];
    
    [@[self.manageView,self.progressView] mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:__I6Width(10) leadSpacing:__I6Width(20) tailSpacing:__I6Width(20)];
    [@[self.manageView,self.progressView] mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(__I6Width(20));
        make.height.mas_offset(__I6Height(90));
        make.bottom.equalTo(self.contentView).offset(-__I6Height(40));
    }];

    [self.progressImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.progressView).offset(__I6Width(10));
        make.top.equalTo(self.progressView).offset(__I6Height(21));
        make.width.height.mas_offset(28);
    }];
    
    [self.progressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.progressImage.mas_left);
        make.top.equalTo(self.progressImage.mas_bottom).offset(__I6Height(15));
        make.bottom.equalTo(self.progressView).offset(-__I6Height(14));
    }];
    
    [self.manageImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.manageView).offset(__I6Width(10));
        make.top.equalTo(self.manageView).offset(__I6Height(21));
        make.width.height.mas_offset(28);
    }];
    
    [self.manageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.manageImage.mas_left);
        make.top.equalTo(self.manageImage.mas_bottom).offset(__I6Height(15));
        make.bottom.equalTo(self.manageView).offset(-__I6Height(14));
    }];

    UIButton * manageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    manageBtn.frame = self.manageView.frame;
    manageBtn.tag = 10003;
    [manageBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.manageView addSubview:manageBtn];
    [manageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.equalTo(self.manageView);
    }];
    
    UIButton * progressBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    progressBtn.tag = 10002;
    [progressBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.progressView addSubview:progressBtn];
    [progressBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.equalTo(self.progressView);
    }];
    
  
}

- (void)btnAction:(UIButton *)btn{
    if ([_delegate respondsToSelector:@selector(didClickAction:)]) {
        [_delegate didClickAction:btn];
    }
}

@end



@implementation JCExplainCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.contentView.backgroundColor = [UIColor colorWithHexString:@"#F7F8FB"];
        UILabel *desLabel = [UILabel new];
        NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc]initWithString:@"一、还款落地商户\n1、还款金额:单笔100-999,单计划不低于600元\n2、手续费为 0.65%/单笔；\n3、支持所有银行；\n4、代扣代还时间要在每天的11-23点之间 ,每天最多3笔；\n\n二、注意事项\n1、如有疑问，请联系客服:18310308601"];
        desLabel.numberOfLines = 0;
        desLabel.textColor = KSHGRAYTEXTCOLOR;
        desLabel.attributedText = attributedStr;
        desLabel.font = KSystemFont(__I6Width(14));
        [self.contentView addSubview:desLabel];
        [desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.equalTo(self.contentView);
            make.left.equalTo(self.contentView).offset(__I6Width(20));
            make.right.equalTo(self.contentView).offset(-__I6Width(20));
        }];

    }
    return self;
}

+ (instancetype)tableViewCellWithTableView:(UITableView *)tableView{
    static NSString * cellIndentfile = @"JCExplainCell";
    JCExplainCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIndentfile];
    
    if (!cell) {
        cell = [[JCExplainCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndentfile];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    return cell;
}

@end

